import java.util.*;
import java.math.*;

public class euler014 {
	
	static final int NMAX = 20;
	static final int TMAX = 8000000;
	
	static public void main(String[] params) {
		Set<Long> used = new HashSet<Long>();
		long n = 1;
		long m = 1;
		long t[] = new long[TMAX];
		int i = 0;
		
		n = 837799;
		while (n > 1) {
			if (n % 2 == 0) {
				n = n / 2;
			} else {
				n = 3*n +1;
			}
			System.out.println(n);
			i++;
		}
		//System.out.println("i="+i);	
		
		n = 1; 
		int j = 0;
		while (j < i) {
			used.add(n);
			if (((n - 1) % 3 == 0) && ((n - 1) / 3) % 3 != 0 && (!used.contains((n - 1) / 3))) {
				n = (n - 1) / 3;
			} else {
				n *= 2;
			}
			//System.out.println(n);
			j++;
		}
		
		//System.out.println(n);
	}
}

	
